package com.sh.high_grade_component;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.sh.high_grade_component.Bean.Planet;
import com.sh.high_grade_component.adapter.PlanetBaseAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ListViewTwoActivity extends AppCompatActivity implements CompoundButton.OnCheckedChangeListener {

    static final int[] iconArray = {
            R.drawable.one, R.drawable.two, R.drawable.three
    };

    static final String[] names = {"名字1", "名字2", "名字3",};
    private ListView listView;
    private CheckBox line;
    private CheckBox bg;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_list_view_two);

        listView = findViewById(R.id.lv_planet);
        List<Planet> defaultList = Planet.getDefaultList();
        PlanetBaseAdapter adapter = new PlanetBaseAdapter(this, defaultList);
        listView.setAdapter(adapter);


        line = findViewById(R.id.ck_line);
        bg = findViewById(R.id.ck_bg);
        line.setOnCheckedChangeListener(this);
        bg.setOnCheckedChangeListener(this);
    }


    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        int id = buttonView.getId();
        if (id == R.id.ck_line) {
            if (line.isChecked()) {
                Drawable drawable = getResources().getDrawable(R.color.black, getTheme());
                listView.setDividerHeight(100);
                listView.setDivider(drawable);
            }else {
                Drawable drawable = getResources().getDrawable(R.color.white, getTheme());
                listView.setDividerHeight(10);
                listView.setDivider(null);
            }
        }
        if (id == R.id.ck_bg) {
            if (bg.isChecked()) {

            }
        }
    }

    @Override
    public void onPointerCaptureChanged(boolean hasCapture) {
        super.onPointerCaptureChanged(hasCapture);
    }
}